trigger convertLeadfromAccount on Account (before insert) {

// create a set of all the unique leadIds
SET<String> emails = new SET<String>();
for (Account a : Trigger.new) {
 if (a.PersonEmail != null) {
  emails.add(a.PersonEmail);
 }
}

Map<String,DateTime> leadMap = new Map<String,DateTime>();
Map<String,Id> leadIds = new Map<String,Id>();
List<id> updateLeads = new List<Id>();

for(Lead l : [select id, email,createddate,status from Lead where email IN :emails]){
   leadMap.put(l.Email,l.createddate);
   leadIds.put(l.Email,l.Id);
}
 
for (Account a : Trigger.new) {

   if(leadMap.containsKey(a.PersonEmail)){
      a.Original_Lead_Create_Date__c = leadMap.get(a.PersonEmail);
      a.Original_Lead__c = leadIds.get(a.PersonEmail);
      updateLeads.add(leadIds.get(a.PersonEmail));
   }
}
   
   if(updateLeads.size() > 0){
       List<Lead> leadList = [SELECT Id, Status FROM Lead WHERE Id in :updateLeads];
       for(integer i = 0 ; i < leadList.size(); i++) {
           leadList[i].Status = 'Qualified';
       }
   update leadList;
   }

}